import { defineStore } from 'pinia'

interface StoredClassInfo {
    classId: number
    className: string
    grade: string
    major: string
    college: string
}

interface TempPatrolData {
    selectedClass?: StoredClassInfo | null
    date?: string
    time?: string
    wsqk?: string
    wsqkValue?: number
    wtqk?: string
    wtqkValue?: number
    wsqk_wt?: string
    wtqk_wt?: string
    photoList?: Array<{name: string, url: string, type?: string}>
}

export const xunkelinshiStore = defineStore('xunkelinshi', {
    state: () => ({
        tempPatrolData: {} as TempPatrolData
    }),
    actions: {
        clearTempData() {
            this.tempPatrolData = {}
        },
        savePatrolData(data: TempPatrolData) {
            this.tempPatrolData = data
        }
    },
    persist: {
        key: 'xunke-patrol-data',
        storage: localStorage,
        paths: ['tempPatrolData']
    }
})